import React from 'react'
import  Register from './container/register/register'
import  Login from './container/login/login'
import  AuthRoute from './components/authRoute/authRouth'
import  BossInfo from './container/bossinfo/bossinfo'
import  Geniusinfo from './container/geniusinfo/geniusinfo'
import  Chat from './components/chat/chat'
import  Dashboard from './components/dashboard/dashboard'
// () => import( /*webpackChunkName: "index" */ '@/components/index/index')

import {BrowserRouter as Router,Link,Route,Redirect,Switch} from 'react-router-dom'
// const Dashboard=(location,cb)=>{
//     require.ensure([], require => {
//         cb(null, require('./components/dashboard/dashboard').default);
//     });
// }
class App extends React.Component{
    constructor(props){
        super(props)
        this.state={
            isError:false
        }
    }
    componentDidCatch(err,info){
        console.log(err)
        this.setState({
            isError:true
        })
        return
    }
    render(){
        return(
            this.state.isError?
            (<h3>出错了啊！！！</h3>)
            :(
            <div className='wrapper'>
                <AuthRoute></AuthRoute>
                
                    <Switch>
                        <Route path='/bossinfo' component={()=>import(/*webpackChunkName:"index"*/ '@/container/bossinfo/bossinfo')}></Route>
                        <Route path='/geniusinfo' component={Geniusinfo}></Route>
                        <Route path='/login' component={Login}></Route>
                        <Route path='/register' component={Register}></Route>
                        <Route path='/chat/:user' component={Chat}></Route>
                    
                        <Route  component={Dashboard}></Route>
                    
                    </Switch>
                
                
            </div>
            )
        )
    }
}
export default App